//
//  StyleSheetView.swift
//  MyCloset
//
//  Created by 牟好好 on 2024/11/29.
//

import SwiftUI

struct StyleSheetView: View {
    @Environment(\.dismiss) var dismiss
    var typeIndex: Int
    let clothStyles = [shangzhuangBase, xiazhuangBase, waitaoBase, xieziBase, maoziBase]
    let imagePrefix = ["shangzhuang", "xiazhuang", "waitao", "xiezi", "maozi"]
    
    var body: some View {
        VStack {
            HStack {
                Spacer()
                Button(action: {
                    dismiss()
                }, label: {
                    Image(systemName: "xmark.app")
                        .foregroundStyle(.yellow)
                        .font(.title)
                })
            }
            
            ScrollView(.vertical, showsIndicators: false) {
                VStack {
                    // \.offset : 以下标作为标识符
                    ForEach(Array(clothStyles[typeIndex].enumerated()), id: \.offset) { index, style in
                        HStack {
                            Text(style)
                                .font(.system(size: boundsWidth * 0.07, weight: .black))
                            Spacer()
                        }
                        Image("\(imagePrefix[typeIndex])\(index)")
                            .resizable()
                            .scaledToFit()
                            .cornerRadius(30)
                            .frame(maxHeight: boundsHeight * 0.2)
                    }
                }
            }
        }
        .padding(.horizontal)
        .padding(.top)
    }
}

#Preview {
    StyleSheetView(typeIndex: 0)
}
